﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HotelManagement.Class;

namespace HotelManagement.UserManagementModule
{
    public partial class CreateAccountForStaff : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            UserAccount us=(UserAccount)Session["object"];
            Label3.Text = us.FirstName + " " + us.LastName;
            
            
            string id = Request.QueryString["sid"]; //staff ID
            Staff stf=HotelDBManager.getStaffInfoByStaffID(id); //staff whose account be created
            Session["staff"]=stf;
            Label4.Text = stf.FirstName + " " + stf.LastName; //staffname
            if (this.ValidateAccountExistsOrNot(id))
            {
                Label1.Text = "Sorry! This Staff's Account already exists in System!";
                Label1.Visible = true;
                Button3.Visible = true;
            }
            else {
                Response.Redirect("~/UserManagementModule/CreateAccountForStaff.aspx");
            }
           
        }

        public bool ValidateAccountExistsOrNot(string id) {
            UserAccount usa = HotelDBManager.accountAlreadyExists(id);
            bool found = false;
            if (usa != null)
            { //account exist and cannot create
                found = true;
            }
            return found;
        }

       
    }
}